﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using www.Stertex.com.Models;

namespace www.Stertex.com.Controllers.Acttributes
{
    public class IsAuthenticatedAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (SessionManager.Profile == null || !SessionManager.Profile.IsAuthenticated)
            {
                var urlHelper = new UrlHelper(filterContext.RequestContext);
                filterContext.HttpContext.Response.Redirect(urlHelper.RouteUrl(new { controller = "Account", action = "Logon" }));

            }
        }
    }
}
